#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
using namespace std;


template<class T>
void myswap(T& a, T& b)
{
	T temp = a;
	a = b;
	b = temp;
}

template<class T>
void mysort(T arr[],int len)
{
	for (int i = 0; i < len; i++)
	{
		int max = i;
		for (int j = i + 1; j < len; j++)
		{
			if (arr[max] < arr[j])
			{
				max = j;
			}
		}
		if (max != i)
		{
			myswap(arr[i], arr[max]);
		}
	}
}


template<class T>
void printarr(T arr[], int len)
{
	for (int i = 0; i < len; i++)
	{
		cout << arr[i] << "";
	}
	cout << endl;

}

void test01()
{
	char chararr[] = "bdcafe";
	int len = sizeof(chararr) / sizeof(char);
	mysort(chararr, len);
	printarr(chararr, len);

}

void test02()
{
	int arr[] = { 1,3,5,7,9,2,4,6,8,0 };
	int len = sizeof(arr) / sizeof(int);
	mysort(arr, len);
	printarr(arr, len);
}


int main()
{
	test01();
	test02();
	return 0;
}